<template>
  <div>
    <el-button class="mt_5" type="primary" size="mini" icon="el-icon-refresh" @click="updateRegion">更新</el-button>
    <el-table :data="regionData" style="margin-bottom: 20px;" row-key="id" border default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
      <el-table-column prop="name" label="区域名称"></el-table-column>
    </el-table>    
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      regionData: [],
    }
  },
  mounted(){
    this.getRegionTreeData();
  },
  methods: {
    getRegionTreeData(){
      request({
        url: '/hikdata/gethikregiontablenode',
        data: {}
      }).then(res => {
        const { data } = res
        this.regionData = data
      })
    },
    updateRegion(){
      request({
        url: '/hikdata/updateregion',
        data: {}
      }).then(res => {
        if(res.code === '200') {
          this.$message.success(res.msg)
          this.getRegionTreeData();
        }
      })
    }
  }      
}
</script>

<style scoped>

</style>
